Read more of this story at Slashdot.
Read more of this story at Slashdot.
A customer wanted to prevent the user from dragging an object into a specific region of their window. Their current implementation detects that the mouse is an in illegal location and uses SetCursorPos to move it to a nearby legal location. However, this creates flicker because the cursor actually does enter the illegal region and then jumps out.
Let’s illustrate this with our scratch program.
POINT g_pt;
const RECT g_rcExclude = { 100, 100, 200, 200 };
RECT ItemRect(POINT pt)
{
return RECT{ pt.x - 10, pt.y - 10, pt.x + 10, pt.y + 10 };
}
The g_pt variable holds the location of our object, and the g_rcExclude is the rectangle in which the object is forbidden. The ItemRect function produces a bounding rectangle for our object so we can draw something there.
void
PaintContent(HWND hwnd, PAINTSTRUCT* pps)
{
FillRect(pps->hdc, &g_rcExclude, (HBRUSH)(COLOR_WINDOWTEXT + 1));
RECT rcItem = ItemRect(g_pt);
FillRect(pps->hdc, &rcItem, (HBRUSH)(COLOR_APPWORKSPACE + 1));
}
Painting our content is a straightforward matter of drawing the forbidden rectangle in the text color and drawing the object in the app workspace color.
void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
{
POINT ptNew = { x, y };
if (PtInRect(&g_rcExclude, ptNew)) {
// Clamp to nearest legal position
int leftMargin = ptNew.x - g_rcExclude.left;
int topMargin = ptNew.y - g_rcExclude.top;
int rightMargin = g_rcExclude.right - ptNew.x;
int bottomMargin = g_rcExclude.bottom - ptNew.y;
int dx, dy;
int x, y;
if (leftMargin < rightMargin) {
x = g_rcExclude.left;
dx = leftMargin;
} else {
x = g_rcExclude.right;
dx = rightMargin;
}
if (topMargin < bottomMargin) {
y = g_rcExclude.top;
dy = topMargin;
} else {
y = g_rcExclude.bottom;
dy = bottomMargin;
}
if (dx < dy) {
ptNew.x = x;
} else {
ptNew.y = y;
}
POINT ptScreen = ptNew;
ClientToScreen(hwnd, &ptScreen);
SetCursorPos(ptScreen.x, ptScreen.y);
}
if (g_pt.x != ptNew.x || g_pt.y != ptNew.y) {
RECT rcItem = ItemRect(g_pt);
InvalidateRect(hwnd, &rcItem, TRUE);
g_pt = ptNew;
rcItem = ItemRect(g_pt);
InvalidateRect(hwnd, &rcItem, TRUE);
}
}
// Add to WndProc
HANDLE_MSG(hwnd, WM_MOUSEMOVE, OnMouseMove);
When the mouse moves, we take the mouse position and see if it is in the forbidden rectangle. If so, we update the coordinates to the nearest legal position and move the mouse there with SetCursorPos.
Whether or not we had to update the coordinates, if the result produces a new location, then invalidate the object’s old location (so it will be erased at the next paint cycle), update the object position, and then invalidate the object’s new position (so it will be drawn at the next paint cycle).
When you run this program, you can try to move the mouse into the forbidden rectangle, but the program will shove the mouse back out. However, it flickers a lot bcause the mouse briefly enters the forbidden rectangle before it is expelled from it.
The customer saw that there is a ClipCursor function to constrain the mouse to remain inside a rectangle, but is there an inverse version that forces the mouse to remain outside a rectangle?
There is no such function, but that’s okay.
What you can do when the mouse is in an illegal position is just pretend that it’s in a legal position. Let the user move the mouse into a illegal position, but show the feedback at the nearest legal position, and if they drop the object, let it drop at the nearest legal position.
In the above program, that means we remove the call to SetCursorPos.
void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
{
POINT ptNew = { x, y };
if (PtInRect(&g_rcExclude, ptNew)) {
// Clamp to nearest legal position
int leftMargin = ptNew.x - g_rcExclude.left;
int topMargin = ptNew.y - g_rcExclude.top;
int rightMargin = g_rcExclude.right - ptNew.x;
int bottomMargin = g_rcExclude.bottom - ptNew.y;
int dx, dy;
int x, y;
if (leftMargin < rightMargin) {
x = g_rcExclude.left;
dx = leftMargin;
} else {
x = g_rcExclude.right;
dx = rightMargin;
}
if (topMargin < bottomMargin) {
y = g_rcExclude.top;
dy = topMargin;
} else {
y = g_rcExclude.bottom;
dy = bottomMargin;
}
if (dx < dy) {
ptNew.x = x;
} else {
ptNew.y = y;
}
// POINT ptScreen = ptNew;
// ClientToScreen(hwnd, &ptScreen);
// SetCursorPos(ptScreen.x, ptScreen.y);
}
if (g_pt.x != ptNew.x || g_pt.y != ptNew.y) {
RECT rcItem = ItemRect(g_pt);
InvalidateRect(hwnd, &rcItem, TRUE);
g_pt = ptNew;
rcItem = ItemRect(g_pt);
InvalidateRect(hwnd, &rcItem, TRUE);
}
}
This time, we don’t try to punish you for moving the mouse into the forbidden rectangle. But the object won’t follow the mouse into a forbidden region.
The post What’s the opposite of <CODE>ClipCursor</CODE> that lets me <I>exclude</I> the cursor from a region? appeared first on The Old New Thing.
Amid intense backlash, the head of the American Diabetes Association posted a video Wednesday apologizing for the organization's decision on Friday to forcefully remove five leading diabetes scientists from the association's annual meeting.
The scientists were ejected for handing out copies of an April editorial—published in the ADA's own journal Diabetes Care—that sharply criticizes the Trump administration for the damage and destruction it's wreaking on biomedical research. The five scientists included Steven Kahn, professor of medicine at the University of Washington, who is the editor-in-chief of Diabetes Care and a co-author of the editorial. It also included former ADA President Desmond Schatz of the University of Florida.
The scientists were distributing the editorial outside the conference's opening speech, which was originally scheduled to be given by Jay Bhattacharya, head of the National Institutes of Health under Trump. Bhattacharya canceled at the last minute, and senior NIH official Rick Woychik took his place.
Within minutes of beginning to hand out the editorial, police reportedly escorted the scientists out of the conference, which was held in New Orleans. The police reportedly shoved at least one scientist, took all of their conference badges, and threatened to arrest them if they tried to return. Louisiana State Police later told media that they acted at the request of the ADA. The ADA subsequently barred the five scientists from the rest of the conference.
In the video Wednesday, ADA CEO Charles Henderson personally apologized to the five scientists, including Aaron Kelly, pediatrics professor at the University of Minnesota; Justin Ryder of Northwestern University; and Irl Hirsch, also of the University of Washington, in addition to Kahn and Schatz.
"What transpired is not reflective of who I am, the values I hold, or the way I was raised," Henderson said. "I will work hard to bring our community back together to build on the progress we have collectively made for those affected by diabetes."
While the ousting immediately stunned and outraged members of the diabetes research community, Henderson's video is in sharp contrast to the ADA's series of statements over the past several days that tried to justify the decision. At first, a media team for the ADA told MedPage Today that "these attendees were escorted out by our onsite event security because they demonstrated behavior not consistent with this code of conduct" for the conference.
In an email to ADA members Saturday, the association said the scientists were removed because they didn't have prior approval to distribute material at the conference and that it was "not because of the viewpoints expressed in those materials," according to reporting from Science.
In a statement Sunday, the organization, which is a nonprofit, said it removed the scientists because it was complying with federal regulations for 501(c)(3) nonprofit, which requires "maintaining a strictly nonpartisan environment at all organizational events and functions while engaging across party affiliations to advance our mission." However, the federal regulations do not restrict leaders of organizations from sharing political views in a personal capacity or from speaking on important public policy issues.
News and video of the incident took off on social media, drawing condemnation and driving a traffic spike to the editorial. Several ADA leaders have resigned amid the backlash. A fiery letter signed by more than 40 ADA officials blasted the decision as "outrageous" and the justifications as "unpersuasive" and "fatuous nonsense." The community is "overwhelmingly repulsed by the way this unfortunate event has occurred and been excused and justified by the Association leadership," the leaders wrote. They demanded "an immediate and unconditional public apology," as well as a review of the incident.
An open letter to the ADA, titled "Shame on You," similarly called for an apology. The attacks from the Trump administration are "bad enough, but the seeming endorsement by the ADA of the current administration's approach to science and of its attacks on freedom of speech is unconscionable." The letter has gathered over 6,500 signatures at the time of publication.
In addition to apologizing to the five ejected scientists, Henderson apologized to the community as a whole, saying that the ADA would commission a "thorough independent review of the events that occurred as well as the policies, procedures, and decision-making process that guided our actions."
"We want to make sure that such incidents do not reoccur," he said.
You press a button to set it in motion, and from there, it's anyone's guess. The screen just makes glitchy patterns at you. The knobs and buttons do... something. Pressing the screen resets. But once it's connected, the AW noise maker opens a wormhole to warped realms of sound.
The post AudioWanderer noise maker is a glitchy, gorgeous, mysterious gem appeared first on CDM Create Digital Music.
For the first time, the American College of Obstetricians & Gynecologists (ACOG) has released its own recommendations for maternal vaccination, providing formal guidance that diverges from that of the Centers for Disease Control and Prevention amid unprecedented policy changes and meddling from anti-vaccine Health Secretary Robert F. Kennedy Jr.
ACOG President Camille Clare blamed "changing national recommendations coupled with rampant vaccine misinformation" for the confusion among patients and health care professionals about vaccines during pregnancy.
"It is incredibly important for the public to have access to reliable, evidence-based information on maternal immunizations from a trusted source. ACOG is proud to be that source," Clare said in a statement.
ACOG's 2026 Maternal Immunization Schedule differs most significantly from the CDC's current schedule by including recommendations for COVID-19 and seasonal influenza vaccines. Those vaccines have been dropped from the CDC's recommendations under Kennedy, in conflict with scientific evidence and amid strong opposition from medical organizations.
Currently, the CDC recommends only two immunizations during pregnancy: Tdap (against tetanus, diphtheria, and pertussis) and RSV (against respiratory syncytial virus). ACOG's new guidance recommends influenza, COVID-19, RSV, and Tdap vaccines. It also provides clear recommendations for additional vaccines for certain populations, as well as vaccinations recommended during postpartum and while breastfeeding.
"Immunizations are an essential part of prepregnancy, prenatal, and postpartum care," said ACOG Chief of Clinical Practice Christopher Zahn in a statement. "As OB-GYNs, we have the power to combat vaccine misinformation on our own platforms, help our patients make educated decisions, and increase confidence in vaccination overall."
Thirteen other medical organizations have already endorsed ACOG's new vaccine recommendations, including the American Academy of Pediatrics (AAP), the American Academy of Family Physicians, the National Association of Nurse Practitioners in Women’s Health, and the American College of Nurse-Midwives.
AAP President Andrew Racine highlighted the need for such guidance, citing the vulnerability of babies. "Their immune systems are still developing, and in those first months of life, they rely on us—the adults around them—to help keep them safe. Maternal vaccines are one of the most effective ways to protect not only the mother but her newborn as well."
Like ACOG, AAP has also released its own childhood vaccine schedule, which conflicts with the CDC's schedule under Kennedy. And like AAP's, its recommendations have been endorsed by a dozen other medical organizations, including the Infectious Diseases Society of America.
The AAP has led the charge against Kennedy's anti-vaccine agenda, spearheading a lawsuit against changes that Kennedy has made to federal vaccine recommendations and the Advisory Committee on Immunization Practices (ACIP), an influential panel of advisors the CDC relies on to set policy. That litigation, which is ongoing, led to a temporary injunction in March that reversed many changes to CDC's vaccine schedule and blocked most of Kennedy's hand-selected ACIP members.
Potentially impacting all AI search engines and chatbots known to poorly paraphrase source links, a German court has ruled that Google is liable for false statements in AI Overviews.
The preliminary ruling came in a case flagged by The Decoder, where two publishers found that Google's AI Overviews incorrectly linked them to scams and other sketchy business practices. After smearing publishers by making affirmative statements like "Yes, [it] is known for dubious business practices and is often perceived as a scam," Google failed to correct the misleading output, even after the publishers sent a cease-and-desist letter earlier this year.
Google tried the usual arguments to shield itself from liability for false statements in AI Overviews, such as arguing that most users understand that AI outputs aren't always accurate and must be verified.
But the court found that, unlike traditional search engines that merely present lists of links to third-party statements, Google's tool made "independent, new, and substantive statements" based on its own misinterpretation of links on the Internet.
That's a problem, the court said, because while publishers may have been able to sue to stop third parties from publishing defamatory statements appearing in Google search results, only Google can correct the underlying algorithm and outputs displayed in AI Overviews. And because, at least initially, the company did not, it therefore "must be held accountable," the court ruled. Beyond that, Google's argument was deemed particularly weak, since the AI overview in this case "contains statements that do not appear in the search results at all."
The court's order—requiring a temporary injunction barring Google from spreading the false claims in any further AI Overviews—may have global implications, as the court seems to be the first to hold an AI firm liable for AI speech.
In the past, AI firms have hoped that disclaimers warning about misinformation would protect them from lawsuits over untrustworthy outputs. Last year, one chatbot maker even argued that AI speech is its own category of "pure speech" and the First Amendment should protect it.
According to a Google translation of the German court ruling, however, the false outputs were "primarily an expression of the defendant’s commercial activity," and the AI tool's "opinions" and false statements were capable of impacting public opinion.
The court concluded that, in weighing the balance, publishers' interest in removing the false information outweighed Google's commercial speech rights.
Historically, any potentially harmful content surfaced by search engines has been protected from direct liability because that surfacing was considered largely unavoidable when helping users sort through an enormous tangle of information online. But the German court emphasized that AI search engines do not enjoy those same protections because AI summaries merely provide "an additional function—one without which the use of the search engine would still be (and is) possible, and without which users are perfectly capable of finding results amidst the 'flood of data.'"
In other words, nobody needs AI to search the Internet, so AI firms can't just let their tools attribute false claims to fake sources without assuming any liability.
The court also seemed to take a dig at Google for expecting users not to "blindly trust" AI overviews, noting that the AI tool's utility "would be significantly diminished if the 'AI overview' were generally regarded as unreliable and if every single displayed link required independent verification."
It seems clear that's not how people approach AI search tools. The Decoder noted a Pew survey last July showing most people don't click on AI Overview source links, as well as a May analysis published by The New York Times that showed that AI Overviews with the current Gemini 3 model are inaccurate about 9 percent of the time and include inaccurate source links about 56 percent of the time.
Together, these findings suggest that Google's AI tool may be cranking out millions of wrong answers daily, with few users verifying the information. Should other courts agree that tech firms are liable for any defamatory outputs emerging from this experimental period of AI search chaos, the biggest AI leaders could find themselves soon buried in lawsuits.
It remains unclear if Google expects to appeal or perhaps start addressing requests to fix false statements in AI Overviews more quickly following the ruling.
Google will likely fight the preliminary ruling. Asked for comment, a Google spokesperson told Ars that "we invest deeply in the quality of AI Overviews to ensure that the overwhelming majority of responses provide accurate information, and they are designed to reflect the information that exists on the web. We’re carefully reviewing this decision, which is not yet final.”
This story was updated to include a statement from Google's spokesperson.